package com.jingsong.studentapp.page;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.jingsong.studentapp.R;
import com.jingsong.studentapp.adapter.AppraisalAdapter;
import com.jingsong.studentapp.lister.OnItemEventListener;
import com.jingsong.studentapp.model.AppraisalModel;

import java.util.ArrayList;

/**
 * 测评阶段
 */
public class AppraisalActivity extends AppCompatActivity implements View.OnClickListener, OnItemEventListener {
    private AppraisalAdapter<AppraisalModel> adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_appraisal);
        ImageView ivBack = findViewById(R.id.ivBack);
        ivBack.setOnClickListener(this);

        TextView tvTitle = findViewById(R.id.tvName);
        tvTitle.setText("测评阶段");

        RecyclerView rcvList = findViewById(R.id.rcvList);
        rcvList.setLayoutManager(new LinearLayoutManager(this));

        adapter = new AppraisalAdapter();
        adapter.setEventListener(this);
        rcvList.setAdapter(adapter);

        ArrayList<AppraisalModel> allDatas = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            AppraisalModel model = new AppraisalModel();
            model.name = "考试名称" + i;
            if (i == 0) {
                model.minNum = 10;
            } else
                model.minNum = 100 / i;
            model.max = 100;
            model.times = "2021-12-10 10:10";
            model.state = i % 4;
            allDatas.add(model);
        }
        adapter.setDatas(allDatas);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.ivBack:
                finish();
                break;
        }
    }

    @Override
    public void onItemEvent(int pos) {
        startActivity(new Intent(AppraisalActivity.this, ClassInfoActivity.class));
    }
}